package com.qiwx.pigeon.presenter;

import com.qiwx.pigeon.base.BasePresenter;
import com.qiwx.pigeon.base.IBaseView;
import com.qiwx.pigeon.data.network.ApiManager;
import com.qiwx.pigeon.data.network.BaseListResponse;
import com.qiwx.pigeon.data.network.BaseResponse;
import com.qiwx.pigeon.data.network.ResponseSubscriber;
import com.qiwx.pigeon.data.params.ChartParam;
import com.qiwx.pigeon.data.vo.ChartFertilizedBeanVo;
import com.qiwx.pigeon.data.vo.GoOutBean;
import com.qiwx.pigeon.data.vo.SummaryCL;
import com.qiwx.pigeon.data.vo.SummaryDaliy;
import com.qiwx.pigeon.viewinterface.IDataChartView;
import com.qiwx.pigeon.viewinterface.IGoOutView;


import java.lang.ref.WeakReference;

import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * @description
 * @Author qiwx
 * @Date 2020-04-26 09:59
 * 数据分析
 **/
public class DataChartPresenter extends BasePresenter<IDataChartView> {

    public DataChartPresenter(WeakReference<IDataChartView> from) {
        super(from);
    }

    public DataChartPresenter(IDataChartView from) {
        super(from);
    }

    //受精分析图
    public void queryChartFertilized(ChartParam params) {
        ApiManager.getApiServer().queryChartFertilized(params)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new ResponseSubscriber<BaseResponse<ChartFertilizedBeanVo>>(true) {
                    @Override
                    public IBaseView getIView() {
                        return getView();
                    }

                    @Override
                    public void onSuccess(BaseResponse<ChartFertilizedBeanVo> response) {
                        getView().onSuccess(response.data);
                    }

                });
    }
    //出栏
    public void queryChartCK(ChartParam params) {
        ApiManager.getApiServer().queryChartCK(params)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new ResponseSubscriber<BaseResponse<SummaryCL>>(true) {
                    @Override
                    public IBaseView getIView() {
                        return getView();
                    }

                    @Override
                    public void onSuccess(BaseResponse<SummaryCL> response) {
                        getView().onSuccess(response.data);
                    }

                });
    }
    //日常统计
    public void queryChartDaliy(ChartParam params) {
        ApiManager.getApiServer().queryChartDaliy(params)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new ResponseSubscriber<BaseListResponse<SummaryDaliy>>(true) {
                    @Override
                    public IBaseView getIView() {
                        return getView();
                    }

                    @Override
                    public void onSuccess(BaseListResponse<SummaryDaliy> response) {
                        getView().onSuccess(response.data);
                    }

                });
    }


}
